package com.shop2cn.iapi.delivery.service;

import org.json.JSONObject;

import com.shop2cn.iapi.delivery.parameter.resp.ImportSqDeliveryResp;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.EnvSetup;

public class ImportSqCheckCall extends YmatouBaseCall {
	
	private static String opurl = "delivery/importSqDeliver";

	public ImportSqCheckCall() {
		super(EnvSetup.getSystemUrl("shop2cn_pretrade"), opurl, "POST", "JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept",
				"text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	/**
	 * 获取BCode
	 * 
	 * @return
	 */
	public int getBCode() {
		int BCode = 0;
		try {
			BCode = new JSONObject(getReturnData()).optInt("BCode");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return BCode;
	}

	/**
	 * 获取Msg
	 * 
	 * @return
	 */
	public String getMsg() {
		String BCode = null;
		try {
			BCode = new JSONObject(getReturnData()).optString("Msg");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return BCode;
	}

	/**
	 * 获取Data
	 * 
	 * @return
	 */
	public JSONObject getData() {
		JSONObject data = null;
		try {
			data = new JSONObject(getReturnData()).optJSONObject("Data");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return data;
	}
	
	/**
	 * 
	 * @return
	 */
	public ImportSqDeliveryResp getDeliveryResp() {
		return (ImportSqDeliveryResp) FormatUtil.GSONToObject(getData().toString(),
				ImportSqDeliveryResp.class);
	}
}
